<%@ page contentType="text/html;charset=UTF-8" language="java" %> <%@ page isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";

%>

<div id="page-content">
    <div class="row">

        <div class="col-lg-12">
            <div class="panel">
                <div class="panel-heading">
                    <h3 class="panel-title">发文管理</h3>
                </div>
                <div class="panel-body">
                    <div class="form-inline">
                        <div class="row">
                            <div class="col-sm-12 table-toolbar-left">
                                <btn id="btn_add_dispatch" class="btn btn-primary btn-sm" ${isCreate}>
                                    <i class="ti-plus"> </i> 新建发文申请表
                                </btn>
                            </div>
                        </div>
                    </div>
                    <div class="table-jqgrid">
                        <table id="dispatch_table"></table>
                        <div id="dispatch_page"></div>
                    </div>
                </div>
            </div>
        </div>

    </div>
</div>

<script>

    $(function(){

        init_grid_dispatch();

    });

    function init_grid_dispatch() {

        __init_jqgrid('dispatch_table', 'dispatch_page',
                '<%=path%>/com/dispatch/list?viewtype=${viewtype}',
                 ['发文类别',"文件编号",'发文标题',"发文时间","文档状态","操作","id"],
                [
                    {name:'type',index:'type', width:100,search:true,sortable:true, searchoptions: {sopt: ['cn']}},
                    {name:'fileNo',index:'fileNo', width:150,sortable:true,search:true, searchoptions: {sopt: ['cn']}},
                    {name:'title',index:'title', width:250,search:true,sortable:true, searchoptions: {sopt: ['cn']}},
                    {name:'time',index:'time',sortable:true,search:true,width:120, searchoptions: {sopt: ['cn']}},
                    {name:'state',index:'state', search:true,sortable:true,width:80, searchoptions: {sopt: ['cn']}},
                    {name:'act',index:'act', width:210,sortable:false,search:false,fixed:true,formatter: actFormat},
                    {name:'id',index:'id',search:false,hidden:true}
                ],
                true,true
        );

    }




    function actFormat(cellvalue, options, rowObject){
        var id = rowObject.id;
        cellvalue = '<button class="btn btn-white btn-sm" onclick="fn_dispatch_read(\'' + id + '\');"><i class="fa fa-eye"> </i> 查看</button>';

        return cellvalue;
    }

    function fn_dispatch_read(id) {
        loadURL('<%=path%>/com/dispatch/read?keyId='+id+'&viewtype=${viewtype}', $('#page-content'));
    }




    $("#btn_add_dispatch").click(function(){
        loadURL('<%=path%>/com/dispatch/input', $('#page-content'));
    });
</script>